home *** CD-ROM | disk | FTP | other *** search
/ Aminet 30 / Aminet 30 (1999)(Schatztruhe)[!][Apr 1999].iso / Aminet / dev / lang / SmallEiffel.lha / SmallEiffel / lib_se / e_check.e < prev    next >
Text File  |  1998-12-22  |  3KB  |  140 lines

  1. --          This file is part of SmallEiffel The GNU Eiffel Compiler.
  2. --          Copyright (C) 1994-98 LORIA - UHP - CRIN - INRIA - FRANCE
  3. --            Dominique COLNET and Suzanne COLLIN - colnet@loria.fr 
  4. --                       http://www.loria.fr/SmallEiffel
  5. -- SmallEiffel is  free  software;  you can  redistribute it and/or modify it 
  6. -- under the terms of the GNU General Public License as published by the Free
  7. -- Software  Foundation;  either  version  2, or (at your option)  any  later 
  8. -- version. SmallEiffel is distributed in the hope that it will be useful,but
  9. -- WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  10. -- or  FITNESS FOR A PARTICULAR PURPOSE.   See the GNU General Public License 
  11. -- for  more  details.  You  should  have  received a copy of the GNU General 
  12. -- Public  License  along  with  SmallEiffel;  see the file COPYING.  If not,
  13. -- write to the  Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  14. -- Boston, MA 02111-1307, USA.
  15. --
  16. class E_CHECK
  17.    --
  18.    -- Instruction "check ... end;".
  19.    --
  20.    
  21. inherit INSTRUCTION redefine is_pre_computable end;
  22.  
  23. creation make
  24.  
  25. feature 
  26.       
  27.    check_invariant: CHECK_INVARIANT;
  28.    
  29. feature {NONE}
  30.    
  31.    current_type: TYPE;
  32.    
  33. feature 
  34.       
  35.    make(sp: like start_position; hc: COMMENT; l: ARRAY[ASSERTION]) is
  36.       require
  37.      sp /= Void;
  38.      not l.empty;
  39.       do
  40.      !!check_invariant.make(sp,hc,l);
  41.       ensure
  42.      start_position = sp;
  43.      check_invariant.list = l;
  44.       end; 
  45.    
  46. feature
  47.  
  48.    end_mark_comment: BOOLEAN is true;
  49.  
  50. feature
  51.    
  52.    start_position: POSITION is
  53.      -- Of keyword "check".
  54.       do
  55.      Result := check_invariant.start_position;
  56.       end;
  57.    
  58.    to_runnable(ct: TYPE): like Current is
  59.       local
  60.      al: like check_invariant;
  61.       do
  62.      if current_type = Void then
  63.         current_type := ct;
  64.         if run_control.all_check then
  65.            al := check_invariant.to_runnable(ct);
  66.            if al = Void then
  67.           error(start_position,"Bad check list.");
  68.            else
  69.           check_invariant := al;
  70.           Result := Current;
  71.            end;
  72.         else
  73.            Result := Current;
  74.         end;
  75.      else
  76.         !!Result.make(start_position,Void,check_invariant.list);
  77.         Result := Result.to_runnable(ct);
  78.      end;
  79.       end;
  80.    
  81.    afd_check is   
  82.       do
  83.      if run_control.all_check then
  84.         check_invariant.afd_check;
  85.      end;
  86.       end;
  87.    
  88.    collect_c_tmp is
  89.       do
  90.       end;
  91.  
  92.    compile_to_c is   
  93.       do
  94.      if run_control.all_check then
  95.         check_invariant.compile_to_c;
  96.      end;
  97.       end;
  98.    
  99.    compile_to_jvm is
  100.       do
  101.      if run_control.all_check then
  102.         check_invariant.compile_to_jvm(true);
  103.         code_attribute.opcode_pop;
  104.      end;
  105.       ensure
  106.      code_attribute.stack_level = old code_attribute.stack_level
  107.       end;
  108.    
  109.    is_pre_computable: BOOLEAN is 
  110.       do
  111.      if run_control.all_check then
  112.         Result := check_invariant.is_pre_computable;
  113.      else
  114.         Result := true;
  115.      end;
  116.       end;
  117.  
  118.    use_current: BOOLEAN is   
  119.       do
  120.      if run_control.all_check then
  121.         Result := check_invariant.use_current;
  122.      end;
  123.       end;
  124.    
  125.    pretty_print is
  126.       do
  127.      check_invariant.pretty_print;
  128.      fmt.put_string("end;");
  129.      if fmt.print_end_check then
  130.         fmt.put_end("check");
  131.      end;
  132.       end;
  133.  
  134. invariant
  135.    
  136.    check_invariant /= Void;
  137.  
  138. end -- E_CHECK
  139.  
  140.